package edu.zut.cs.software.cms.module.course.dao;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import edu.zut.cs.software.cms.base.dao.GenericDao;
import edu.zut.cs.software.cms.module.course.domain.Course;
/**
 * 
 * @author 24372
 *
 */
@Repository
public interface CourseDao  extends GenericDao<Course, Long>{
	@Query(value="  SELECT * FROM `cms`.`t_course` WHERE `id`=?1 ",nativeQuery=true)
	Course selectById(@Param("id") Long id);
	
	@Query(value="  SELECT * FROM `cms`.`t_course` ",nativeQuery=true)
	List<Course> selectAlls();
	
	@Query(value="  DELETE * FROM `cms`.`t_course` WHERE `id`=?1 ",nativeQuery=true)
	void deleteById(@Param("id") Long id);
	
	@Query(value="  SELECT * FROM `cms`.`t_course` WHERE `id`=?1 ",nativeQuery=true)
	Course modifyById(@Param("id")long id);
	

	@Query(value="  SELECT COUNT(*) FROM `cms`.`t_course` WHERE `name`=?1 ",nativeQuery=true)
	int IfOneExist(@Param("name")String name);
}
